package org.langqiao.jvm.oom;

import java.util.ArrayList;
import java.util.List;

public class HeapOOM {

	static class OOMObject {
		
	}
	
	public static void main(String[] args) {
		/*List<OOMObject> list = new ArrayList<HeapOOM.OOMObject>();
		while(true){
			list.add(new OOMObject());
		}*/
		testJvmMethod1();
  	}
	
	//jvm方法区
	public static void testJvmMethod(){
		List<String> list = new ArrayList<String>();
		int i = 0;
		while(true){
			list.add(String.valueOf(i).intern());
		}
	}

	
	public static void testJvmMethod1(){
		String str1 = new StringBuilder("hua").append("chao").toString();
		System.out.println(str1.intern() == str1);
		//jvm中内部在加载类的时候，就已经有"java"这个字符窜，不符合首次出现的原则
		String str2 = new StringBuilder("ja").append("va").toString();
		System.out.println(str2.intern() == str2);
	}
}
